package com.leon.android.component.mine

import com.apkfuns.logutils.LogUtils
import com.google.gson.reflect.TypeToken
import com.leon.android.arch.mvvv.base.BaseFragment
import com.leon.android.common.bean.User
import com.leon.android.common.proxy.SpProperty
import kotlinx.android.synthetic.main.mine_fragment.*
import org.jetbrains.anko.sdk27.coroutines.onClick

/**
 * @time:2019/12/16 10:21
 * @author:Leon
 * @description:
 */
class MineFragment : BaseFragment() {

    override fun getLayoutID() = R.layout.mine_fragment

    var user: User? by SpProperty("user", User::class.java)

    var users: MutableList<User?>? by SpProperty("users", object : TypeToken<List<User>>() {}.type)

    var uid = 1L

    var usid = 1L

    override fun initView() {
        saveSpBtn.onClick {
            user = User("leon", uid++)
            users = mutableListOf(
                User("test$usid", usid++),
                User("test$usid", usid++),
                User("test$usid", usid++),
                User("test$usid", usid++)
            )
        }

        readSpBtn.onClick {
            LogUtils.d("uid : $uid   usid : $usid")
            LogUtils.d(user)
            LogUtils.d(users)
        }
    }

    override fun initData() {
    }

    override fun bindModel() {
    }
}